#@head() 
#@header()
<title>融资需求管理</title>
#@aside("custser")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
			#@custsermenu("trends")
           
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				
				<div class="box-body">
					<table id="example1" class="table table-striped">
						<thead>
							<tr>
								<th>ID</th>
								<th>时间</th>	
								<th>用户名</th>
								<th>真实姓名</th>
								<th>所属客服</th>
								<th>动态信息</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="shenheall">

						</tbody>
					</table>
				</div>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id = "shall1"><a href="#">首页</a></li>
					<li id = "shall2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="shall5"></span>页 共<span id="shall6"></span>页</a></li>
					<li id = "shall3"><a href="#">下一页</a></li>
					<li id = "shall4"><a href="#">尾页</a></li>
				  </ul>
				</div>
              </div>
            <!-- /.tab-content -->
          </div>
	</section>
</div>
#@footer()
 <script id="shenhejieguo" type="text/x-jquery-tmpl">
	<tr>
		<td>${id}</td>
		<td>${create_time}</td>
		<td>${mobile}</td>
		<td>${real_name}</td>
		<td>${agent}</td> 
		<td>${agent_contents}</td>
		<td><span pass="${id}" class="badge pass ${cla}">${status}</span></td>
	</tr>
</script>
<script>
function shall(page,startime,endtime,bidname){
	$.getJSON("/merit/assetsLog?token=#(session.token??)&page="+page+"&size=14", function(shlist) {
		console.log(shlist);
		totalPage = shlist.data.page.totalPage;
		$("#shall6").html(totalPage);
		$.each(shlist.data.page.list, function(i, item){ 
			var aa=item.agent_is_read;
			var cla="";
			if(aa=="1"){
				var status = "已读";
				cla="bg-green";
			}else if(aa=="0"){
				cla="bg-red";
				var status = "未读";
			}
			var jieguolist = {id:item.id,agent:item.agent_name,id:item.id,cla:cla,status:status,create_time:item.create_time,agent_contents:item.agent_contents,real_name:item.real_name,mobile:item.mobile};
			$("#shenhejieguo").tmpl(jieguolist).appendTo('#shenheall');
		});
		$(".pass").click(function(){
			var that = $(this);
			var idval = that.attr("pass");
			
			$.getJSON("/notice/setRead?token=#(session.token??)&role=agent&type=assets&id="+idval, function(data) {
				if(data.code=='success'){
					layer.msg(data.msg, {icon:1,time:1000},function(){
						that.addClass("bg-green");
						that.html("已读");
					});
				}else if(data.code=='error'){
					layer.msg(data.msg, {icon:2,time:1000});
				}
			});
		});
	});
}
var startime = "";
var endtime ="";
var bidname = "";
 $(document).ready(function(){ 
	$("#shenheall").empty();
	shall(1);
	pageNumber = 1;
	totalPage = 1;
	$("#shall5").html(pageNumber);
});
$("#shall1").click(function(){
	$("#shenheall").empty();
	shall(1);
	pageNumber = 1;
	$("#shall5").html(pageNumber);
});
$("#shall2").click(function(){
	if(pageNumber==1){
		alert("当前页是首页!");
	}else{
	$("#shenheall").empty();
	pageNumber = pageNumber-1;
	shall(pageNumber);
	$("#shall5").html(pageNumber);
	}
});
$("#shall3").click(function(){
	if(pageNumber==totalPage){
		alert("当前页是尾页!");
	}else{
	$("#shenheall").empty();
	pageNumber = pageNumber +1;
	shall(pageNumber);
	$("#shall5").html(pageNumber);
	}
});
$("#shall4").click(function(){
	$("#shenheall").empty();
	shall(totalPage);
	pageNumber = totalPage;
	$("#shall5").html(pageNumber);
});
$("#bidseach").click(function(){
	$("#shenheall").empty();
	startime = $("#startime").val()+" 00:00:00";
	
	endtime = $("#endtime").val()+" 24:00:00";
	
	bidname = $("#bidname").val();
	
	shall(1,startime,endtime,bidname);
	pageNumber = 1;
	$("#shall5").html(pageNumber);
});
</script> 

</body>
</html>
